package world.hezi.utils;

import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.ArrayList;
import java.util.List;

public class LinuxCommandUtil {
	
	public static List<String> execCommand(String command) {
		// 命令执行后的输出内容
		List<String> outputList = new ArrayList<>();
		try{
			Process process = Runtime.getRuntime().exec(command);
			InputStreamReader ir = new InputStreamReader(process.getInputStream());
			LineNumberReader input = new LineNumberReader(ir);
			String line;
			process.waitFor();
			while((line = input.readLine()) != null) {
				outputList.add(line);
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return outputList;
	}
}